package com.example.patient.jpa;

import com.example.common.entity.LogisticsD;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Author wxy
 * @Date 2021/1/22 10:00
 * @Version 1.0
 */
public interface LogisticsDRepository extends JpaRepository<LogisticsD, String> {

    Long countByOrderNoAndOrderType(String orderNo, Integer orderType);

    @Query(value = "select * from shop_order_logistics where order_type_tinyint = 1 and order_no_nvarchar in (:RxOrderNOs)",nativeQuery = true)
    List<LogisticsD> findByOrderType(@Param("RxOrderNOs") List<String> RxOrderNOs);

    @Query(value = "select max(waybill_nvarchar) from shop_order_logistics where l_type_int = 0 and waybill_nvarchar like CONCAT(?1,'%') ",nativeQuery = true)
    String findMaxWaybill(String code);

    @Query(value = "select count(1) from shop_order_logistics where waybill_nvarchar = ?1",nativeQuery = true)
    Integer countByWaybill(String Waybill);
}
